<!DOCTYPE html>
<html>
<head>
    {include file="common/meta"}

    <style>
        .control-sidebar-default {
            background-color: #ffffff;
            box-shadow: 0 0 15px 0 rgba(0,0,0,.05);
        }
        .control-sidebar-default .control-sidebar-content{
            padding: 24px;
            line-height: 1.5;
        }
        .control-sidebar-default .title {
            color: rgba(0,0,0,.66);
            font-weight: normal;
            font-size: 13px;
        }
    </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed text-sm" data-panel-auto-height-mode="height">
<div class="wrapper">
    <!-- 侧边栏 -->
    <aside class="main-sidebar sidebar-dark-teal elevation-4">
        <!-- 左上角标题 -->
        <a href="" class="brand-link">
            <img src="__static__/img/bt.png" class="brand-image img-circle elevation-3" style="opacity: .8">
            <span class="brand-text font-weight-light">{:__('Backstage panel')}</span>
        </a>

        <div class="sidebar">
            <!-- 菜单栏目 -->
            <nav class="mt-3">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false" id="userMenu"></ul>
            </nav>
        </div>
    </aside>

    <!-- 导航栏 -->
    <div class="content-wrapper iframe-mode" data-widget="iframe" data-loading-screen="0">
        <div class="nav navbar navbar-expand navbar-white navbar-light border-bottom p-0 main-header2">
            <!--收缩菜单栏-->
            <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>

            <!--子页管理、标签切换-->
            <a class="nav-link bg-light" href="#" data-widget="iframe-scrollleft"><i class="fas fa-angle-double-left"></i></a>
            <ul class="navbar-nav overflow-hidden" role="tablist">
                <li class="nav-item active default-page" role="presentation">
                    <a class="nav-link active" data-toggle="row" id="tab-index" href="#panel-{:str_replace(['.','/'],'-',url('/index/dashboard'))}" role="tab" aria-controls="panel-{:str_replace(['.','/'],'-',url('/index/dashboard'))}" aria-selected="true">{:__("Dashboard")}</a>
                </li>
            </ul>
            <a class="nav-link bg-light" href="#" data-widget="iframe-scrollright"><i class="fas fa-angle-double-right"></i></a>

            <!--垃圾清理、标签关闭-->
            <div class="dropdown">
                <a class="nav-link" data-toggle="dropdown" href="#" id="delop">
                    <i class="far fa-trash-alt"></i>
                </a>
                <div class="dropdown-menu dropdown-menu-right J-clearCache accent-teal" aria-labelledby="delop">
                    <a class="dropdown-item" href="#" data-widget="iframe-close" data-type="all">{:__('Close all subpages')}</a>
                    <a class="dropdown-item" href="#" data-widget="iframe-close" data-type="all-other">{:__('Close all other')}</a>
                    {if app('user')->hasSuperAdmin()}
                    <div class="dropdown-divider"></div>
                    <a href="#" data-url="{:url('/index/clearCache',['type'=>'all'])}" class="dropdown-item J_item">{:__("Clean all")}</a>
<!--                    <div class="dropdown-divider"></div>-->
<!--                    <a href="#" data-url="{:url('/index/clearCache',['type'=>'data'])}" class="dropdown-item J_item">{:__("Clean up all data caches")}</a>-->
                    <a href="#" data-url="{:url('/index/clearCache',['type'=>'log'])}" class="dropdown-item J_item">{:__("Clean up all logs")} <span style="color: #6c757d" data-toggle="tooltip" data-placement="top" data-title="清理程序产生日志文件"><i class="fa  fa-info-circle"></i></span></a>
<!--                    <a href="#" data-url="{:url('/index/clearCache',['type'=>'temp'])}" class="dropdown-item J_item">{:__("Clean up all page caches")}</a>-->
                    {/if}
                </div>
            </div>

            <!--用户登录信息-->
            <div class="dropdown user-image">
                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" title="{$User['nickname']??$User['username']}">
                    <img src="{:empty($User['avatar'])?'__static__/img/user.png':$User['avatar']}" class="img-circle elevation-2">
                </a>
                <ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right border-0">
                    <li class="user-header bg-teal">
                        <img src="{:empty($User['avatar'])?'__static__/img/user.png':$User['avatar']}" class="img-circle elevation-2 text-white">
                        <p>
                            <span>{$User['nickname']??$User['username']}</span>
                            <small>{$User['group_names']}</small>
                            <small>{:__("Last login time")} {$User['lasttime']}</small>
                        </p>
                    </li>
                    <li class="user-footer">
                        <a href="{:url('/index/profile')}" class="btn btn-default  btn-newMenu" data-id="88" data-title="{:__("Profile")}">{:__("Profile")}</a>
                        <a href="{:url('/login/logout')}" class="btn btn-default float-right">{:__("Sign out")}</a>
                    </li>
                </ul>
            </div>

            <!--语言切换-->
            <div class="dropdown">
                <a class="nav-link" data-toggle="dropdown" href="#">
                    <i class="fas fa-language"></i>
                </a>
                <div class="dropdown-menu dropdown-menu-right accent-teal" id="J-lang">
                    {volist name="langs['admin_lang']['data_list']" id="item"}
                    <a href="{:url('/index/index',['lang'=>$key])}" class="dropdown-item {if (app()->lang->getLangSet()==$key)}active{/if}">{$item}</a>
                    {/volist}
                    <div class="dropdown-divider"></div>
                    {if $site['content_lang_on']==1}
                    <span class="text-secondary dropdown-item-text" style="font-size: 12px">{:__('Content lang mode')}</span>
                    {volist name="langs['content_lang']['data_list']" id="item"}
                    <a href="{:url('/index/changeContentLang',['l'=>$key,'t'=>$item])}" class="dropdown-item J-content-model {if ($site['content_lang_mode']==$key)}active{/if}">{$item}</a>
                    {/volist}
                    {/if}
                </div>
            </div>

            <a class="nav-link" data-widget="control-sidebar" data-controlsidebar-slide="true" href="#" role="button">
                <i class="fas fa-cogs"></i>
            </a>

            <!--模板管理-->
            <div class="dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fas fa-home"></i> {:__("Home")}
                </a>
                <div class="dropdown-menu dropdown-menu-right accent-teal">
                    <?php $lan = cookie('index_'.config('lang')['cookie_var']);?>
                    {volist name="langs['index_lang']['data_list']" id="item"}
                    <a href="/?lang={$key}" class="dropdown-item {if ($lan==$key)}active{/if}" target="_blank">{$item}</a>
                    {/volist}

                    {if !empty($langs['index_lang']['data_list'])}
                    <div class="dropdown-divider"></div>
                    {/if}

                    <a href="/" class="dropdown-item" target="_blank"><i class="fa fa-external-link-alt"></i> {:__('To Home')}</a>

                    {if get_addons_config('template',site('index_theme'),'index')}
                    <a href="#" onclick="cmsOpen('{:url('/appcenter/setConfig',['name'=>site('index_theme'),'type'=>'template','popup'=>1,'module'=>'index'])}','{:__('Theme configuration')}');return false;" class="dropdown-item" target="_blank"><i class="fa fa-cog"></i> {:__('Theme configuration')}</a>
                    {/if}
                    <a href="#" onclick="cmsOpen('{:url('/appcenter/editTheme')}?name={:site('index_theme')}&type=template&popup=1&module=index&t=tpl','{:__('Theme management')}');return false;" class="dropdown-item" target="_blank"><i class="far fa-folder"></i> {:__('Theme management')}</a>
                    <a href="#!" class="dropdown-item btn-exp"><i class="far fa-file-archive"></i> {:__('Export all')}</a>
                </div>
            </div>
        </div>
        <div class="tab-content">
            <div class="tab-pane default-page fade active show" id="panel-{:str_replace(['.','/'],'-',url('/index/dashboard'))}" role="tabpanel" aria-labelledby="tab-{:str_replace(['.','/'],'-',url('/index/dashboard'))}">
                <iframe src="{:url('/index/dashboard')}"></iframe>
            </div>
            <div class="tab-empty">
                <h2 class="display-4">No tab selected!</h2>
            </div>
            <div class="tab-loading">
                <div>
                    <h3 class="display-4">Tab is loading <i class="fa fa-sync fa-spin"></i></h3>
                </div>
            </div>
        </div>
    </div>

    <!-- 风格控制面板 -->
    <aside class="control-sidebar control-sidebar-default">
        <div class="control-sidebar-content">
            <form class="frm-operate">
                <h5>{:__('Background settings')}</h5>
                <hr>
                <h6>{:__('Global Settings')}</h6>
                <div class="mb-2 d-flex align-items-center">
                    <div class="mr-2 title">{:__('Popup full screen')}:</div>
                    <div class="custom-control custom-switch custom-switch-on-teal " data-toggle="tooltip" data-trigger="hover" data-placement="top" data-original-title="{:__('Click to switch')}">
                        <input type="checkbox" class="custom-control-input" id="switchismenu_0" name="row[popup]" value="2" {if $Tpl.popup=="2"}checked=""{/if}>
                        <label class="custom-control-label" for="switchismenu_0"></label>
                    </div>
                </div>
                <div class="mb-4 d-flex align-items-center">
                    <label class="m-0 title">{:__('Default paging size')}：</label>
                    <input type="number" value="{$Tpl.page}" class="form-control" style="width: 80px;height:1.5rem" name="row[page]">
                </div>
                <h6>{:__('Content page')}</h6>
                <div class="mb-2">
                    <div class="mb-1 title">弹出框行为:</div>
                    <div class="d-flex align-items-center">
                        <label class="d-flex align-items-center mr-1" style="cursor: pointer">
                            <input type="radio" value="1" class="mr-1" name="row[c_popup]" {if $Tpl.c_popup=="1"}checked{/if}>
                            <span>{:__('Default')}</span>
                        </label>
                        <label class="d-flex align-items-center mr-1" style="cursor: pointer">
                            <input type="radio" value="2" class="mr-1" name="row[c_popup]" {if $Tpl.c_popup=="2"}checked{/if}>
                            <span>{:__('Full screen')}</span>
                        </label>
                        <label class="d-flex align-items-center mr-1" style="cursor: pointer">
                            <input type="radio" value="3" class="mr-1" name="row[c_popup]" {if $Tpl.c_popup=="3"}checked{/if}>
                            <span>{:__('New window')}</span>
                        </label>
                    </div>
                </div>
                <div class="mb-2 d-flex align-items-center">
                    <div class="mr-2 title">{:__('Content list contains subordinates')}:</div>
                    <div class="custom-control custom-switch custom-switch-on-teal " data-toggle="tooltip" data-trigger="hover" data-placement="top" data-original-title="{:__('Click to switch')}">
                        <input type="checkbox" class="custom-control-input" id="switchismenu_1" name="row[c_sub]" value="1" {if $Tpl.c_sub=="1"}checked{/if}>
                        <label class="custom-control-label" for="switchismenu_1"></label>
                    </div>
                </div>
            </form>
        </div>
    </aside>
</div>
<!-- ./wrapper -->

{include file="common/script"}

<script>
    function getMenuList() {  // 获取菜单并显示页面
        Util.ajax({ url:"{:url('/Index/menu')}",async:true },'',function (data) {
            $('#userMenu').html(data);
        });
    }

    require(['jquery','bootstrap','adminlte','layer'], function ($,undefined,adminlte,undefined) {
        // 缓存清理
        $('.J-clearCache').on('click','.J_item',function (e) {
            Util.ajax({ url:$(this).data('url') },'',function (data,res) {
                Layer.msg(res.msg, {time:1000, icon: 1});
            });
        })

        $('#J-lang').on('click','.J-content-model',function (e) {
            var that = this;
            layer.confirm('{:__("Page will reload")}', {
                btn : [ '{:__("Confirm")}', '{:__("Cancel")}' ]
            }, function(idx) {
                layer.close(idx);
                Util.ajax({ url:$(that).attr('href') },'',function (data,res) {
                    Layer.msg(res.msg, {time:2000, icon: 1}, function () {
                        window.location.reload();
                    });
                });
            });
            e.preventDefault();
        })

        // 初始化菜单
        getMenuList();

        $('.frm-operate').change(function (e) {
            var data = $(this).serializeArray();
            var popup = "row[popup]";
            var c_sub = "row[c_sub]";
            $.each(data, function (idx, vo) {
                if (vo.name==popup) {
                    popup = "";return true;
                }
                if (vo.name==c_sub) {
                    c_sub = "";return true;
                }
            });
            if (popup) {
                data.push({name:popup,value:1});
            }
            if (c_sub) {
                data.push({name:c_sub,value:2});
            }

            $.post('{:url("/appcenter/setConfig",["type"=>"template","module"=>"admin","name"=>"adminlte"])}',data,function (data) {
                layer.msg(data.msg);
            });
        })

        $('[data-toggle="tooltip"]').tooltip();

        // 导出
        $('.btn-exp').click(function (e) {
            layer.prompt({title: '请填写新的应用标识', formType: 3}, function(url, index){
                window.open("{:url('/appcenter/packCode',['name'=>site('index_theme')])}&newname="+url);
                layer.close(index);
            });
        });
    })
</script>

</body>
</html>